package com.cy.mybatis.sqlsession.defaults;

import com.cy.mybatis.sqlsession.SqlSession;
import com.cy.mybatis.sqlsession.SqlSessionFactory;
import com.cy.utils.XMLConfigBuilder;

import java.io.InputStream;

/**
 * @Author : 残影
 * @Date: 2020-09-11 09:53
 */
public class DefaultSqlSessionFactory implements SqlSessionFactory {
    private InputStream config = null;
    public void setConfig(InputStream config) {
        this.config = config; }
    @Override
    public SqlSession openSession() {
        DefaultSqlSession session = new DefaultSqlSession();
        //调用工具类解析 xml 文件
        XMLConfigBuilder.loadConfiguration(session, config);
        return session; }
}
